import json
import requests
import oss2
import time


def dd_message(content):
    token="https://oapi.dingtalk.com/robot/send?access_token=4f12412d8a035913c93db3d9700b808d46b469e2119190e3c85479ef80453268"  #这里替换为你刚才复制的内容
    headers={'Content-Type':'application/json'}
    data={"msgtype":"markdown","markdown":{"title":"pi", "text":content}}
    requests.post(token,data=json.dumps(data),headers=headers)

def dd_image(picURL):
    dd_message("![图片](%s)" % picURL)
    
def oss2_upload(local_filename, remote_filename):
    try:
        id = 'LTAI5tSCXqouJdoJBTcpY4Lm'
        key = 'H3tgLG9HP960408YYFYsUCFQIKEmEK'
        endpoint = 'oss-accelerate.aliyuncs.com'
        bucket_name = 'snrmyi'
        auth = oss2.Auth(id, key)
        bucket = oss2.Bucket(auth, endpoint, bucket_name)
        bucket.put_object_from_file(remote_filename, local_filename)
        return True
    except:
        print('将本地文件%s传入对象存储中名为%s失败!' % (local_filename, remote_filename))
        return False
